package it.gnocco.grafo;

import java.awt.Color;
import java.util.ArrayList;

import it.gnocco.log.Logger;
import it.gnocco.properties.Property;
import it.gnocco.robotica.Robot;


public class Nodo {
	private int _id = 0;
	private Robot robot_presente = null;
	private ArrayList<Nodo> nodi_vicini = new ArrayList<Nodo>();
	private static final String CLASS = "Nodo";
	public Color colore = Color.white;
	
	
	public Nodo(int id){
		_id = id;
	}
	
	public int getID(){
		return _id;
	}
	
	public boolean equals(Nodo n){
		if(_id == n._id){
			return true;
		}
		return false;
	}
	
	public int hashCode(){
		return Integer.valueOf(_id).hashCode();
	}
	
	public void addRobot(Robot r){
		colore = r.colore;
		robot_presente = r;
	}

	public void removeRobot(Robot r){
		if(robot_presente.equals(r))
			robot_presente = null;
	}
	public void removeAllRobot(){
		robot_presente = null;
	}

	public void addNodo(Nodo n){
		nodi_vicini.add(n);
	}

	public Nodo getNodo(int i){
		return nodi_vicini.get(i);
	}

	public int sizeVicini(){
		return nodi_vicini.size();
	}

	public void removeNodo(Nodo n){
		nodi_vicini.remove(n);
	}
	
	public void removeAllNodi(){
		nodi_vicini = new ArrayList<Nodo>();
	}
	
	public String toString(){
		return "nodo "+_id;
	}
	
	public boolean equals(Object o){
		try{
			if(!(o instanceof Nodo))
				return false;
		}catch (Exception e){
			return false;
		}
		if(this._id != ((Nodo)o)._id)
			return false;
		return true;
	}
	
}
